﻿using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace ChangeLanguage
{
    /// <summary>
    /// ViewA.xaml 的交互逻辑
    /// </summary>
    public partial class ViewA : Window
    {
        public ViewA()
        {
            InitializeComponent();
            InitComboBox();
        }
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var item = ChangeComboBox.SelectedItem as ValueText;
            if (item != null)
            {
                ResourceService.Current.ChangedCulture(item.Text);
            }
        }
        private void InitComboBox()
        {
            ChangeComboBox.ItemsSource = ResourceService.Languages;
            ChangeComboBox.DisplayMemberPath = "Text";
            ChangeComboBox.SelectedValuePath = "Value";
            ChangeComboBox.SelectedValue = ResourceService.Languages.FirstOrDefault(t => t.Text == Properties.Settings.Default.Language).Value;
        }
    }
}
